import type {
  EmployeeAddReq,
  EmployeeAssignRoleReq,
  EmployeeQuery,
  EmployeeResp,
  EmployeeToggleEnabledReq,
  EmployeeUpdateReq,
} from '@/model/sys/employeeModel'
import { defHttp } from '@/utils/http/axios'

enum Path {
  List = '/employee/list',
  ToggleEnabled = '/employee/toggle-enabled',
  Add = '/employee/add',
  Update = '/employee/update',
  Detail = '/employee/detail',
  ResetPwd = '/employee/reset-pwd',
  AssignRoles = '/employee/assign-roles',
}

export const employeeApi = {
  add(params: EmployeeAddReq) {
    return defHttp.post({ url: Path.Add, params })
  },
  update(params: EmployeeUpdateReq) {
    return defHttp.post({ url: Path.Update, params })
  },
  detail(employeeId: string) {
    return defHttp.post<EmployeeResp>({ url: Path.Detail, params: {
      employeeId,
    } })
  },
  list(params: EmployeeQuery) {
    return defHttp.post({ url: Path.List, params })
  },
  toggleEnabled(params: EmployeeToggleEnabledReq) {
    return defHttp.post({ url: Path.ToggleEnabled, params })
  },
  resetPwd(employeeId: string) {
    return defHttp.post<EmployeeResp>({ url: Path.ResetPwd, params: {
      employeeId,
    } })
  },
  assignRoles(params: EmployeeAssignRoleReq) {
    return defHttp.post({ url: Path.AssignRoles, params })
  },
}
